<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索结果 - ShopEase</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#FF7D00',
                        neutral: {
                            100: '#F5F7FA',
                            200: '#E5E6EB',
                            300: '#C9CDD4',
                            400: '#86909C',
                            500: '#4E5969',
                            600: '#272E3B',
                            700: '#1D2129',
                        }
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
           .content-auto {
                content-visibility: auto;
            }

           .card-shadow {
                box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            }

           .card-hover {
                transition: transform 0.3s ease, box-shadow 0.3s ease;
            }

           .card-hover:hover {
                transform: translateY(-5px);
                box-shadow: 0 10px 30px rgba(22, 93, 255, 0.15);
            }

           .scrollbar-hide::-webkit-scrollbar {
                display: none;
            }

           .scrollbar-hide {
                -ms-overflow-style: none;
                scrollbar-width: none;
            }
        }
    </style>
</head>

<body class="font-inter bg-neutral-100 text-neutral-700">
    <!-- 导航栏 -->
    <nav class="sticky top-0 z-50 bg-white shadow-md transition-all duration-300">
        <div class="container mx-auto px-4">
            <div class="flex items-center justify-between h-16 md:h-20">
                <!-- Logo -->
                <a href="/" class="flex items-center space-x-2">
                    <span class="text-primary text-2xl font-bold">ShopEase</span>
                </a>

                <!-- 搜索框 -->
                <div class="hidden md:flex flex-1 max-w-xl mx-8 relative">
                    <form action="/search" method="GET">
                        <input type="text" id="search-input" name="query" placeholder="搜索商品..."
                            class="w-full pl-4 pr-10 py-2 rounded-full border border-neutral-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all">
                        <button type="submit" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-neutral-400 hover:text-primary transition-colors">
                            <i class="fa fa-search"></i>
                        </button>
                    </form>
                    <div id="search-suggestions" class="absolute top-full left-0 right-0 hidden"></div>
                </div>

                <!-- 导航链接 -->
                <div class="flex items-center space-x-4 md:space-x-6">
                    <a href="/search" class="text-neutral-500 hover:text-primary transition-colors hidden md:block">
                        <i class="fa fa-search text-lg"></i>
                    </a>
                    <a href="#" class="text-neutral-500 hover:text-primary transition-colors relative">
                        <i class="fa fa-shopping-cart text-lg"></i>
                        <span class="absolute -top-2 -right-2 bg-secondary text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">3</span>
                    </a>
                    <a href="#" class="text-neutral-500 hover:text-primary transition-colors">
                        <i class="fa fa-heart-o text-lg"></i>
                    </a>
                    <a href="#" class="text-neutral-500 hover:text-primary transition-colors">
                        <i class="fa fa-user-o text-lg"></i>
                    </a>
                </div>
            </div>

            <!-- 移动端搜索框 -->
            <div class="md:hidden pb-4 relative">
                <form action="/search" method="GET">
                    <input type="text" id="search-input-mobile" name="query" placeholder="搜索商品..."
                        class="w-full pl-4 pr-10 py-2 rounded-full border border-neutral-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all">
                    <button type="submit" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-neutral-400 hover:text-primary transition-colors">
                        <i class="fa fa-search"></i>
                    </button>
                </form>
                <div id="search-suggestions-mobile" class="absolute top-full left-0 right-0 hidden"></div>
            </div>
        </div>
    </nav>

    <!-- 主内容 -->
    <main class="container mx-auto px-4 py-8">
        <h1 class="text-3xl font-bold text-neutral-700 mb-8">搜索结果</h1>

        <!-- 显示搜索结果 -->
        <section class="mb-12">
            {% if products %}
            <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
                {% for product in products %}
                <div class="bg-white rounded-lg overflow-hidden card-shadow card-hover">
                    <div class="relative">
                        <img src="{{ product.image_url }}" alt="{{ product.name }}" class="w-full h-48 object-cover">
                        <button class="absolute top-2 right-2 bg-white/80 hover:bg-white text-neutral-500 hover:text-secondary rounded-full p-2 transition-colors">
                            <i class="fa fa-heart-o"></i>
                        </button>
                    </div>
                    <div class="p-4">
                        <div class="flex items-center text-yellow-400 text-sm mb-1">
                            <i class="fa fa-star"></i>
                            <i class="fa fa-star"></i>
                            <i class="fa fa-star"></i>
                            <i class="fa fa-star"></i>
                            <i class="fa fa-star-o"></i>
                            <span class="text-neutral-500 ml-1">({{ product.reviews_count }})</span>
                        </div>
                        <h3 class="font-medium text-base mb-2 line-clamp-2">{{ product.name }}</h3>
                        <div class="flex justify-between items-center">
                            <span class="text-primary font-bold">¥{{ product.price }}</span>
                            <button class="bg-primary/10 hover:bg-primary/20 text-primary rounded-full p-2 transition-colors">
                                <i class="fa fa-shopping-cart"></i>
                            </button>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
            {% else %}
            <p class="text-neutral-500 text-lg">未找到符合条件的商品，请尝试更换关键词重新搜索。</p>
            {% endif %}
        </section>
    </main>

    <!-- 页脚 -->
    <footer class="bg-neutral-700 text-white py-12 mt-16">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4">ShopEase</h3>
                    <p class="text-neutral-300 mb-4">简单便捷的购物体验，尽在ShopEase。</p>
                    <div class="flex space-x-4">
                        <a href="#" class="text-neutral-300 hover:text-white transition-colors">
                            <i class="fa fa-facebook"></i>
                        </a>
                        <a href="#" class="text-neutral-300 hover:text-white transition-colors">
                            <i class="fa fa-twitter"></i>
                        </a>
                        <a href="#" class="text-neutral-300 hover:text-white transition-colors">
                            <i class="fa fa-instagram"></i>
                        </a>
                        <a href="#" class="text-neutral-300 hover:text-white transition-colors">
                            <i class="fa fa-linkedin"></i>
                        </a>
                    </div>
                </div>

                <div>
                    <h4 class="font-medium text-lg mb-4">快速链接</h4>
                    <ul class="space-y-2">
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">首页</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">商品分类</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">新品上市</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">热销商品</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">关于我们</a></li>
                    </ul>
                </div>

                <div>
                    <h4 class="font-medium text-lg mb-4">客户服务</h4>
                    <ul class="space-y-2">
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">联系我们</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">常见问题</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">配送政策</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">退换货政策</a></li>
                        <li><a href="#" class="text-neutral-300 hover:text-white transition-colors">隐私政策</a></li>
                    </ul>
                </div>

                <div>
                    <h4 class="font-medium text-lg mb-4">订阅我们</h4>
                    <p class="text-neutral-300 mb-4">订阅我们的新闻通讯，获取最新优惠和产品信息。</p>
                    <form class="flex">
                        <input type="email" placeholder="输入您的邮箱" class="flex-1 px-4 py-2 rounded-l-md text-neutral-700 focus:outline-none">
                        <button type="submit" class="bg-primary hover:bg-primary/90 transition-colors px-4 py-2 rounded-r-md">
                            订阅
                        </button>
                    </form>
                </div>
            </div>

            <div class="border-t border-neutral-600 mt-8 pt-8 text-center text-neutral-400">
                <p>&copy; 2025 ShopEase. 保留所有权利。</p>
            </div>
        </div>
    </footer>

    <script>
        // 导航栏滚动效果
        window.addEventListener('scroll', function () {
            const nav = document.querySelector('nav');
            if (window.scrollY > 10) {
                nav.classList.add('shadow-lg');
                nav.classList.add('bg-white/95');
                nav.classList.add('backdrop-blur-sm');
            } else {
                nav.classList.remove('shadow-lg');
                nav.classList.remove('bg-white/95');
                nav.classList.remove('backdrop-blur-sm');
            }
        });
    </script>
</body>

</html>